
package provider.WzXML;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import provider.DbgDataDirectoryEntry;
import provider.DbgDataEntity;
import provider.DbgDataEntry;
import provider.DbgDataFileEntry;

public class WZDirectoryEntry extends WZEntry implements DbgDataDirectoryEntry {

    private List<DbgDataDirectoryEntry> subdirs = new ArrayList<DbgDataDirectoryEntry>();
    private List<DbgDataFileEntry> files = new ArrayList<DbgDataFileEntry>();
    private Map<String, DbgDataEntry> entries = new HashMap<String, DbgDataEntry>();

    public WZDirectoryEntry(String name, int size, int checksum, DbgDataEntity parent) {
	super(name, size, checksum, parent);
    }

    public WZDirectoryEntry() {
	super(null, 0, 0, null);
    }

    public void addDirectory(DbgDataDirectoryEntry dir) {
	subdirs.add(dir);
	entries.put(dir.getName(), dir);
    }

    public void addFile(DbgDataFileEntry fileEntry) {
	files.add(fileEntry);
	entries.put(fileEntry.getName(), fileEntry);
    }

    public List<DbgDataDirectoryEntry> getSubdirectories() {
	return Collections.unmodifiableList(subdirs);
    }

    public List<DbgDataFileEntry> getFiles() {
	return Collections.unmodifiableList(files);
    }

    public DbgDataEntry getEntry(String name) {
	return entries.get(name);
    }
}
